<?php

namespace app\manage\services;
/**
 * 抽像的基类
 */
abstract class BaseService
{


    /**
     * 获取诮
     * @param string $app_name 应用名
     * @return array
     * @throws \yiqiniu\extend\exception\ApiException
     */
    protected function getRouteList(string $app_name): array
    {
        $routhFile = app()->getBasePath() . $app_name . DIRECTORY_SEPARATOR . 'route' . DIRECTORY_SEPARATOR . 'route.json';
        if (!is_file($routhFile)) {
            api_exception(400, '路由文件不存在或已删除');
        }

        $jsonRules = json_decode(file_get_contents($routhFile), true, 512);
        if (empty($jsonRules)) {
            api_exception(400, '路由文件解析失败,请检查文件');
        }
        return $jsonRules;
    }
}